package hu.dynamicwebshop.languagemanager;

import hu.dynamicwebshop.daos.impls.TextDAOImpl;
import hu.dynamicwebshop.entities.Text;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;

/**
 *
 * @author Szecskó Zoltán <zoltan.szecsko@gmail.com>
 */
public class LanguageManager implements Serializable {

    private static final long serialVersionUID = 1L;
    private HashMap<String, String> outputTextMap = new HashMap<String, String>();
    private String countryCode;
    @Autowired
    private TextDAOImpl tdi;

    public void putTextsToOutputTextMap() {
        List<Text> texts = tdi.findByCountryCode(countryCode);

        for (Text t : texts) {
            if (outputTextMap.get(t.getTextId()) == null) {
                outputTextMap.put(t.getTextId(), t.getOutputText());
            }
        }
    }

    public HashMap<String, String> getOutputTextMap() {
        return outputTextMap;
    }

    public void setOutputTextMap(HashMap<String, String> outputTextMap) {
        this.outputTextMap = outputTextMap;
    }

    public String getCountryCode() {
        return countryCode;
    }

    public void setCountryCode(String countryCode) {
        this.countryCode = countryCode;
    }
}
